// pages/Home/content/content.js
var app = getApp();
var ikz = require('../../Common/tools.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    replydis: 'none',//回复是否显示
    head_info: '',//优选信息
    advert: '',//广告信息
    zanhead: 'wei',//本条消息是否赞过
    iscollect: 'wei',//本条消息是否赞过
    hid: '',//本条信息id
    inputValue: '',//评论输入框内容
    comment_time_info: '',//最新评论信息
    comment_like_info: '',//精彩评论信息
    isallzan: 2,//2可以操作点赞，3不可以，防止重复点击
    iscol: 2,//2可以操作收藏，3不可以，防止重复点击
    imgnum: 1,//banner第几张
    isChecked: false,
    showView: false, //发表弹窗
    all_img:'',
    isFold:false,
    relevel: '1',//评论级别，1是本条信息（一级评论），2是二级评论，3是三级评论
    mid: '0',//所评论id
    fid: '0',//所评论的父级评论id
    ismore: '2',//查看更多
    remarkshow: 'none' //不回复的情况下 点击遮罩层消失
  },
  // 点击查看更多评论
  clickmore: function (e) {
    var hid = this.data.hid;
    var that = this;
    var head_info = that.data.head_info;
    var data = {
      hid: hid,
    };
    var path = 'Index/clickMoreCon';
    ikz.request(path, data, false, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        that.setData({
          comment_time_info: res.data.comment_time_info,
          ismore: 3,
        });
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        })
      }
    });
  },
  // 点击收回更多评论
  clickless: function (e) {
    var that = this;
    var comment_time_info = that.data.comment_time_info;
    comment_time_info.length = 2;
    that.setData({
      comment_time_info: comment_time_info,
      ismore: '2',
    });

  },
  //溢出隐藏样式
  flodFn: function () {
    console.log('改变样式')
    this.setData({
      isFold: !this.isFold
    });
  },
  
  // 点击回复按钮
  reply: function (e) {
    console.log(e.currentTarget.dataset)
    var mid = e.currentTarget.dataset.mid;
    var fid = e.currentTarget.dataset.fid;
    var relevel = e.currentTarget.dataset.relevel;
    var that = this;
    that.setData({
      relevel: relevel,
      fid: fid,
      mid: mid,
      showView: (!that.data.showView),
      remarkshow: 'block'
    })
  },
  catchtabinput: function () {
    var that = this;
    that.setData({
      remarkshow: 'block'
    })
  },
  // 不回复 点击关闭
  close: function () {
    var that = this;
    that.setData({
      remarkshow: 'none'
    })
  },
 
 
  
  
  //banner变化
  swiperChange: function (e) {
    var imgnum = e.detail.current + 1;
    this.setData({
      imgnum: imgnum,
    });
  },

  serviceSelection:function(){
    this.setData({
      isChecked: true
    })  
  },

  //获取视频评论输入框内容
  textValue: function (e) {
    this.setData({
      inputValue: e.detail.value,
      relevel: '1',
      mid: '0',
    })
  },
  //获取评论输入框内容
  bindKeyInput: function (e) {
    var that = this;
    this.setData({
      inputValue: e.detail.value,
    })
  },
  //发表评论
  makeConComment: function (e) {
    var that = this;
    var com_content = that.data.inputValue;
    var comment_time_info = that.data.comment_time_info;
    var comment_like_info = that.data.comment_like_info;
    //判断评论不能为空
    if (com_content == '') {
      wx.showToast({
        title: '请填写评论',
        duration: 2000
      });
      return false;
    }
    var hid = that.data.hid;
    var mid = that.data.mid;
    var fid = that.data.fid;
    var relevel = that.data.relevel;
    var data = {
      mid: mid,
      hid: hid,
      com_content: com_content,
    }
    var path = 'Index/makeConComment';
    ikz.request(path, data, true, (res) => {
      if (res.data.status == 'success') {
        if (comment_time_info.length){
          if(relevel == '1'){
            res.data.comment_info['com_time_son_info'] = [];
            comment_time_info.unshift(res.data.comment_info);
          } else if (relevel == '2'){
            res.data.comment_info['com_time_san_info'] = [];
            for (var i = 0; i < comment_time_info.length; i++) {
              if (mid == comment_time_info[i].com_id){
                comment_time_info[i].com_time_son_info.unshift(res.data.comment_info);
              }
            }
          } else if (relevel == '3'){
            for (var i = 0; i < comment_time_info.length; i++) {
              if (fid == comment_time_info[i].com_id) {
                for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++){
                  if (mid == comment_time_info[i].com_time_son_info[k].com_id){
                    comment_time_info[i].com_time_son_info[k].com_time_san_info.unshift(res.data.comment_info);
                  }
                }
              }
            }
          }
        }
        if (comment_like_info.length) {
          if (relevel == '2') {
            res.data.comment_info['com_like_san_info'] = [];
            for (var i = 0; i < comment_like_info.length; i++) {
              if (mid == comment_like_info[i].com_id) {
                comment_like_info[i].com_like_son_info.unshift(res.data.comment_info);
              }
            }
          } else if (relevel == '3') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (fid == comment_like_info[i].com_id) {
                for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                  if (mid == comment_like_info[i].com_like_son_info[k].com_id) {
                    comment_like_info[i].com_like_son_info[k].com_like_san_info.unshift(res.data.comment_info);
                  }
                }
              }
            }
          }
        }
        wx.showToast({
          title: '发表成功！',
          duration: 2000
        });
        that.setData({
          comment_time_info: comment_time_info,
          comment_like_info: comment_like_info,
          showView: false,
          inputValue: '',
          remarkshow: 'none'
        })
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        })
      }

    });
  },
  // 点击收藏
  collectTop: function (e) {
    var hid = this.data.hid;
    var that = this;
    //防止重复点击
    that.setData({
      iscol: 3,
    });
    var data = {
      hid: hid,
    };
    var path = 'Index/collectHead';
    ikz.request(path, data, true, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        wx.showToast({
          title: '收藏成功！',
          duration: 2000
        });
        that.setData({
          iscollect: 'yi',
        });
      } else if (res.data.status == 'fails') {
        wx.showToast({
          title: '已收藏！',
          duration: 2000
        });
        that.setData({
          iscollect: 'yi',
        });
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        });
      }
      that.setData({
        iscol: 2,
      });
    });
  },
  // 取消收藏
  collectTops: function (e) {
    var hid = this.data.hid;
    var that = this;
    //防止重复点击
    that.setData({
      iscol: 3,
    });
    var data = {
      hid: hid,
    };
    var path = 'Index/collectCancle';
    ikz.request(path, data, true, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        wx.showToast({
          title: '取消收藏成功！',
          duration: 2000
        });
        that.setData({
          iscollect: 'wei',
        });
      } else if (res.data.status == 'fails') {
        wx.showToast({
          title: '已取消收藏！',
          duration: 2000
        });
        that.setData({
          iscollect: 'wei',
        });
      }  else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        });
      }
      that.setData({
        iscol: 2,
      });
    });
  },
  //本条消息点赞
  goHeadLike: function (e) {
    var hid = this.data.hid;
    var head_info = this.data.head_info;
    var that = this;
    var data = {
      hid: hid,
    };
    that.setData({
      isallzan: 3,
    });
    var path = 'Index/goHeadLike';
    ikz.request(path, data, false, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        head_info.head_like = parseInt(head_info.head_like) + 1;
        that.setData({
          head_info: head_info,
          zanhead: 'yi',
        })
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        })
      }
      that.setData({
        isallzan: 2,
      });
    });
  },
  //本条消息取消点赞
  noHeadLike: function (e) {
    var hid = this.data.hid;
    var head_info = this.data.head_info;
    var that = this;
    var data = {
      hid: hid,
    };
    that.setData({
      isallzan: 3,
    });
    var path = 'Index/noHeadLike';
    ikz.request(path, data, false, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        head_info.head_like = parseInt(head_info.head_like) - 1;
        that.setData({
          head_info: head_info,
          zanhead: 'wei',
        });
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        });
      }
      that.setData({
        isallzan: 2,
      });
    });
  },
  //评论点赞
  goComLike: function (e) {
    var that = this;
    var mid = e.currentTarget.dataset.mid;//本评论id
    var yid = e.currentTarget.dataset.yid;//爷评论id
    var fid = e.currentTarget.dataset.fid;//父评论id
    var typ = e.currentTarget.dataset.typ;
    var relevel = e.currentTarget.dataset.relevel;
    var comment_time_info = that.data.comment_time_info;
    var comment_like_info = that.data.comment_like_info;
    var data = {
      comid: mid,
    };
    that.setData({
      isallzan: 3,
    });
    var path = 'Index/goComLike';
    ikz.request(path, data, false, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        if (typ == 'zuixin') {
          if (relevel == '1') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (mid == comment_time_info[i].com_id) {
                comment_time_info[i].iszan = 'yi';
                comment_time_info[i].com_like = parseInt(comment_time_info[i].com_like) + 1;
              }
            }
          } else if (relevel == '2') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (fid == comment_time_info[i].com_id) {
                for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                  if (mid == comment_time_info[i].com_time_son_info[k].com_id) {
                    comment_time_info[i].com_time_son_info[k].iszan = 'yi';
                    comment_time_info[i].com_time_son_info[k].com_like = parseInt(comment_time_info[i].com_time_son_info[k].com_like) + 1;
                  }
                }
              }
            }
          } else if (relevel == '3') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (yid == comment_time_info[i].com_id) {
                for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                  if (fid == comment_time_info[i].com_time_son_info[k].com_id) {
                    for (var m = 0; m < comment_time_info[i].com_time_son_info[k].com_time_san_info.length; m++) {
                      if (mid == comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_id) {
                        comment_time_info[i].com_time_son_info[k].com_time_san_info[m].iszan = 'yi';
                        comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_like = parseInt(comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_like) + 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }else{
          if (relevel == '1') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (mid == comment_like_info[i].com_id) {
                comment_like_info[i].iszan = 'yi';
                comment_like_info[i].com_like = parseInt(comment_like_info[i].com_like) + 1;
              }
            }
          } else if (relevel == '2') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (fid == comment_like_info[i].com_id) {
                for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                  if (mid == comment_like_info[i].com_like_son_info[k].com_id) {
                    comment_like_info[i].com_like_son_info[k].iszan = 'yi';
                    comment_like_info[i].com_like_son_info[k].com_like = parseInt(comment_like_info[i].com_like_son_info[k].com_like) + 1;
                  }
                }
              }
            }
          } else if (relevel == '3') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (yid == comment_like_info[i].com_id) {
                for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                  if (fid == comment_like_info[i].com_like_son_info[k].com_id) {
                    for (var m = 0; m < comment_like_info[i].com_like_son_info[k].com_like_san_info.length; m++) {
                      if (mid == comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_id) {
                        comment_like_info[i].com_like_son_info[k].com_like_san_info[m].iszan = 'yi';
                        comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_like = parseInt(comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_like) + 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
        
        that.setData({
          comment_time_info: comment_time_info,
          isallzan: 2,
          comment_like_info: comment_like_info,
        });
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        });
      }
    });
  },
  //评论取消点赞
  noComLike: function (e) {
    var that = this;
    var mid = e.currentTarget.dataset.mid;//本评论id
    var yid = e.currentTarget.dataset.yid;//爷评论id
    var fid = e.currentTarget.dataset.fid;//父评论id
    var typ = e.currentTarget.dataset.typ;
    var relevel = e.currentTarget.dataset.relevel;
    var comment_time_info = that.data.comment_time_info;
    var comment_like_info = that.data.comment_like_info;
    var data = {
      comid: mid,
    };
    that.setData({
      isallzan: 3,
    });
    var path = 'Index/noComLike';
    ikz.request(path, data, false, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        if (typ == 'zuixin') {
          if (relevel == '1') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (mid == comment_time_info[i].com_id) {
                comment_time_info[i].iszan = 'wei';
                comment_time_info[i].com_like = parseInt(comment_time_info[i].com_like) - 1;
              }
            }
          } else if (relevel == '2') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (fid == comment_time_info[i].com_id) {
                for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                  if (mid == comment_time_info[i].com_time_son_info[k].com_id) {
                    comment_time_info[i].com_time_son_info[k].iszan = 'wei';
                    comment_time_info[i].com_time_son_info[k].com_like = parseInt(comment_time_info[i].com_time_son_info[k].com_like) - 1;
                  }
                }
              }
            }
          } else if (relevel == '3') {
            for (var i = 0; i < comment_time_info.length; i++) {
              if (yid == comment_time_info[i].com_id) {
                for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                  if (fid == comment_time_info[i].com_time_son_info[k].com_id) {
                    for (var m = 0; m < comment_time_info[i].com_time_son_info[k].com_time_san_info.length; m++) {
                      if (mid == comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_id) {
                        comment_time_info[i].com_time_son_info[k].com_time_san_info[m].iszan = 'wei';
                        comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_like = parseInt(comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_like) - 1;
                      }
                    }
                  }
                }
              }
            }
          }
        } else {
          if (relevel == '1') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (mid == comment_like_info[i].com_id) {
                comment_like_info[i].iszan = 'wei';
                comment_like_info[i].com_like = parseInt(comment_like_info[i].com_like) - 1;
              }
            }
          } else if (relevel == '2') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (fid == comment_like_info[i].com_id) {
                for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                  if (mid == comment_like_info[i].com_like_son_info[k].com_id) {
                    comment_like_info[i].com_like_son_info[k].iszan = 'wei';
                    comment_like_info[i].com_like_son_info[k].com_like = parseInt(comment_like_info[i].com_like_son_info[k].com_like) - 1;
                  }
                }
              }
            }
          } else if (relevel == '3') {
            for (var i = 0; i < comment_like_info.length; i++) {
              if (yid == comment_like_info[i].com_id) {
                for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                  if (fid == comment_like_info[i].com_like_son_info[k].com_id) {
                    for (var m = 0; m < comment_like_info[i].com_like_son_info[k].com_like_san_info.length; m++) {
                      console.log();
                      if (mid == comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_id) {
                        comment_like_info[i].com_like_son_info[k].com_like_san_info[m].iszan = 'wei';
                        comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_like = parseInt(comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_like) - 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }

        that.setData({
          comment_time_info: comment_time_info,
          comment_like_info: comment_like_info,
          isallzan: 2,
        });
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        });
      }
    });
  },
  //删除评论
  delCom: function (e) {
    var that = this;
    var mid = e.currentTarget.dataset.mid;//本评论id
    var yid = e.currentTarget.dataset.yid;//爷评论id
    var fid = e.currentTarget.dataset.fid;//父评论id
    var typ = e.currentTarget.dataset.typ;
    var relevel = e.currentTarget.dataset.relevel;
    var comment_time_info = that.data.comment_time_info;
    var comment_like_info = that.data.comment_like_info;
    var hid = this.data.hid;
    
    var data = {
      comid: mid,
      hid: hid,
    };
    wx.showModal({
      title: '提示',
      content: '您确认删除评论吗？',
      success: function (res) {
        if (res.confirm) {
          var path = 'Index/delCom';
          ikz.request(path, data, true, (res) => {
            console.log(res);
            if (res.data.status == 'success') {
              wx.showToast({
                title: '删除评论成功！',
                duration: 2000
              });
              if (typ == 'zuixin') {
                if (relevel == '1') {
                  var z = -1;
                  for (var i = 0; i < comment_time_info.length; i++) {
                    if (mid == comment_time_info[i].com_id) {
                      z = i;
                    }
                  }
                  if (z > -1) {
                    comment_time_info.splice(z, 1);
                  };
                } else if (relevel == '2') {
                  var z = -1;
                  var x = -1;
                  for (var i = 0; i < comment_time_info.length; i++) {
                    if (fid == comment_time_info[i].com_id) {
                      z = i;
                      for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                        if (mid == comment_time_info[i].com_time_son_info[k].com_id) {
                          x = k;
                        }
                      }
                    }
                  }
                  if (x > -1) {
                    comment_time_info[z].com_time_son_info.splice(x, 1);
                  };
                } else if (relevel == '3') {
                  var z = -1;
                  var x = -1;
                  var c = -1;
                  for (var i = 0; i < comment_time_info.length; i++) {
                    if (yid == comment_time_info[i].com_id) {
                      z = i;
                      for (var k = 0; k < comment_time_info[i].com_time_son_info.length; k++) {
                        if (fid == comment_time_info[i].com_time_son_info[k].com_id) {
                          x = k;
                          for (var m = 0; m < comment_time_info[i].com_time_son_info[k].com_time_san_info.length; m++) {
                            if (mid == comment_time_info[i].com_time_son_info[k].com_time_san_info[m].com_id) {
                              c = m;
                            }
                          }
                        }
                      }
                    }
                  }
                  if (c > -1) {
                    comment_time_info[z].com_time_son_info[x].com_time_san_info.splice(c, 1);
                  };
                }
              } else {
                if (relevel == '1') {
                  var z = -1;
                  for (var i = 0; i < comment_like_info.length; i++) {
                    if (mid == comment_like_info[i].com_id) {
                      z = i;
                    }
                  }
                  if (z > -1) {
                    comment_like_info.splice(z, 1);
                  };
                } else if (relevel == '2') {
                  var z = -1;
                  var x = -1;
                  for (var i = 0; i < comment_like_info.length; i++) {
                    if (fid == comment_like_info[i].com_id) {
                      z = i;
                      for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                        if (mid == comment_like_info[i].com_like_son_info[k].com_id) {
                          x = k;
                        }
                      }
                    }
                  }
                  if (x > -1) {
                    comment_like_info[z].com_like_son_info.splice(x, 1);
                  };
                } else if (relevel == '3') {
                  var z = -1;
                  var x = -1;
                  var c = -1;
                  for (var i = 0; i < comment_like_info.length; i++) {
                    if (yid == comment_like_info[i].com_id) {
                      z = i;
                      for (var k = 0; k < comment_like_info[i].com_like_son_info.length; k++) {
                        if (fid == comment_like_info[i].com_like_son_info[k].com_id) {
                          x = k;
                          for (var m = 0; m < comment_like_info[i].com_like_son_info[k].com_like_san_info.length; m++) {
                            if (mid == comment_like_info[i].com_like_son_info[k].com_like_san_info[m].com_id) {
                              c = m;
                            }
                          }
                        }
                      }
                    }
                  }
                  if (c > -1) {
                    comment_like_info[z].com_like_son_info[x].com_like_san_info.splice(c, 1);
                  };
                }
              }
              that.setData({
                comment_time_info: comment_time_info,
                comment_like_info: comment_like_info,
              })
            } else if (res.data.status == 'haveson') {
              wx.showModal({
                title: '提示',
                content: '本评论有子评论，不能删！',
                showCancel: false
              })
            } else if (res.data.status == 'nochom') {
              wx.showModal({
                title: '提示',
                content: '不是本人评论，不能删！',
                showCancel: false
              })
            } else {
              wx.showModal({
                title: '提示',
                content: '服务器繁忙，请稍后重试！',
                showCancel: false
              })
            }

          });
        } else if (res.cancel) {
          return false;
        }
      }
    })

  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var hid = options.hid;
    ikz.over(this);
    this.setData({
      hid: hid,
      remarkshow: 'none'
    });

  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.videoContext = wx.createVideoContext('myVideo');
    //this.videoContext.requestFullScreen();
  },
  

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var hid = this.data.hid;
    var that = this;
    var data = {
      hid: hid,
    }
    if (app.globalData.openUserInfo == '') {
      var islogin = false;
    }else{
      var islogin = true;
    }
    var path = 'Index/content';
    ikz.request(path, data, islogin, (res) => {
      console.log(res);
      if (res.data.status == 'success') {
        var head_info = res.data.head_info;
        if (head_info.head_red_ismature == 2 && head_info.head_red_id > 0) {
          var noticedis = 'block';
        } else {
          var noticedis = 'none';
        }
        that.setData({
          all_img: res.data.head_info.head_img,
          head_info: res.data.head_info,
          advert_info: res.data.advert_info,
          noticedis: noticedis,
          hid: hid,
          iscollect: res.data.iscollect,
          comment_time_info: res.data.comment_time_info,
          comment_like_info: res.data.comment_like_info,
          isallzan: 2,
        });
        ikz.hide(that);
      } else {
        wx.showModal({
          title: '提示',
          content: '服务器繁忙，请稍后重试！',
          showCancel: false
        })
      }

    });
    
  },
  //图片点击事件
  toImg: function (event) {
    var src = event.currentTarget.dataset.src;//获取data-src
    var imgList = this.data.all_img;//获取data-list
    //图片预览
    wx.previewImage({
      current: src, // 当前显示图片的http链接
      urls: imgList // 需要预览的图片http链接列表
    })
  },

    //跳转到图片页
  // toImg: function (e) {
  //   var id = e.currentTarget.dataset.id;
  //   var typ = 'tou';
  //   var data = {
  //     id: id,
  //     typ: typ,
  //   }

  //   ikz.nav('../images/images', 'n', data);
  // },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    console.log(111)

    
  },
   getRandomColor() {
    let rgb = []
    for (let i = 0; i < 3; ++i) {
      let color = Math.floor(Math.random() * 256).toString(16)
      color = color.length == 1 ? '0' + color : color
      rgb.push(color)
    }
    return '#' + rgb.join('')
  },
  inputValue: '',
  bindInputBlur: function (e) {
    this.inputValue = e.detail.value
  },
  // 发表评论
  bindSendDanmu: function () {
    this.videoContext.sendDanmu({
      text: this.inputValue,
      color: this.getRandomColor()
    })
  },


})